<template>
  <div class="resumeItemContainer">
    <div class="resumeItemTitle">
      <div class="resumeItemTitleFlag"></div>
      <span class="resumeItemTitleContent">技能特长</span>
      <span class="resumeItemTitleAddIcon" @click="handleAddClick" v-if="!resumeData"> <img :src="resumeItemAddIcon"
          class="resumeItemAddIcon">添加</span>
    </div>
    <div class="resumeItemMain">
      <div class="resumeItemDisplayList">
        <div class="resumeItemDisplayItem">
          <div class="resumeItemDisplayItemEditButtons">
            <template v-if="!editStatus">
              <span class="resumeItemDisplayItemEditButton" @click="changeEditStatusForSingle(true)">
                <img :src="myResumeEditIcon" /> 编辑</span>
              <!-- <span class="resumeItemDisplayItemEditButton" @click="handleDeletClick()">
                <img :src="myResumeDeleteIcon" />删除</span> -->
            </template>
          </div>
          <div class="displayBlock" v-if="!editStatus">
            <div class="summaryContainer">
              <div class="summary richContent" :ref="`richContent`" v-html="resumeData"></div>
              <div class="expendContainer" @click="expandContentForSingle()" v-if="showExpend">
                <el-button type="text" :icon="expendButtonText=='展开'?'el-icon-arrow-down':'el-icon-arrow-up'">
                  {{expendButtonText||"展开"}}
                </el-button>
              </div>
            </div>
          </div>
          <div class="editBlock" v-else :id="editStatus?'edittingBlock':''">
            <div class="resumeItemEdit">
              <el-form ref="form" :model="editForm" inline>
                <el-form-item label="" class="textAreaFormItem">
                  <el-input type="textarea" :rows="10" placeholder="请输入技能特长" v-model="editForm.resumeData"
                    :maxlength="1600" show-word-limit>
                  </el-input>
                </el-form-item>
                <el-form-item class="wholeLineFormItem">
                  <div class="submitButtons">
                    <el-button size="small" @click="handleCancel">取 消</el-button>
                    <el-button size="small" type="primary" @click="handleSave">完 成</el-button>
                  </div>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</template>

<script>
import myResumeItemsMixin from "@/mixin/myResumeItemsMixin.js";
export default {
  name: "skillInfo",
  mixins: [myResumeItemsMixin],
  props: {
    resumeData: {
      type: String,
      default: () => "",
    },
    editStatus: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      showExpend: false,
      expendButtonText: "展开",
      editForm: { resumeData: "" }, //
    };
  },
  watch: {
    resumeData: {
      immediate: true,
      handler(newValue, oldValue) {
        //console.log("技能特长skillsInfo更新：", newValue);
        this.editForm.resumeData = newValue;
        this.isOverflowingForSingle(this, `richContent`);
      },
    },
  },
  methods: {
    handleAddClick() {
      this.editForm.resumeData = "";
      this.changeEditStatusForSingle(true);
    },
    async handleSave() {
      const finalParams = {
        op: "person_info_busi",
        func: "updatePersonDetail",
        version: "v7.8.5",
        forName: "iphone",
        param: {
          person_id: this.personId,
          param: {
            personId: this.personId,
            where: `id='${this.personId}'`,
            update: [
              {
                columnName: "otherTc",
                columnValue: this.editForm.resumeData,
              },
            ],
          },
        },
      };
      //console.log("修改技能特长：", finalParams);
      this.resumeGeneralInterface(
        finalParams,
        () => {
          this.changeEditStatusForSingle(false);
        },
        () => {}
      );
    },
    handleCancel() {
      this.changeEditStatusForSingle(false);
      this.editForm.resumeData = this.resumeData;
    },
    handleDeletClick() {
      //console.log("点击了删除");
    },
    handleCancelClick() {
      this.changeEditStatusForSingle(false);
    },
  },
};
</script>

<style lang="scss" scoped>
.resumeItemContainer {
  display: flex;
  flex-direction: column;
  margin: 20px 0 16px;
  .resumeItemTitle {
    display: flex;
    align-items: center;
    .resumeItemTitleFlag {
      width: 4px;
      height: 19px;
      background: #0b6eff;
      border-radius: 2px;
      margin-right: 10px;
    }
    .resumeItemTitleContent {
      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      font-size: 20px;
      color: #333333;
      margin-right: 19px;
    }
    .resumeItemTitleAddIcon {
      display: flex;
      align-items: center;
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #4880ff;
      cursor: pointer;
      .resumeItemAddIcon {
        width: 20px;
        height: 20px;
        margin-right: 8px;
      }
    }
  }
  .resumeItemMain {
    margin-top: 16px;
    .resumeItemDisplayList {
      .resumeItemDisplayItem {
        position: relative;
        margin-bottom: 16px;
        &:last-of-type {
          margin-bottom: 0px;
        }

        &:hover {
          .displayBlock {
            background: #f8f8f8;
            border-radius: 8px;
            padding: 16px 16px 16px 16px;
          }
          .resumeItemDisplayItemEditButtons {
            display: block;
          }
        }
        .resumeItemDisplayItemEditButtons {
          display: none;
          position: absolute;
          top: -18px;
          right: 0;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 15px;
          color: #4880ff;
          line-height: 18px;
          & > span {
            display: inline-flex;
            align-items: center;
            cursor: pointer;
            margin-left: 23px;
            user-select: none;
            & > img {
              width: 16px;
              height: 16px;
              margin-right: 5px;
            }
          }
        }
        .displayBlock {
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 15px;
          // margin-right: 150px;
          color: #666666;
          line-height: 18px;
          text-align: left;
          font-style: normal;
          .displayInfo {
            display: flex;
            align-items: center;
          }
          .summary {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 14px;
            color: #888888;
            line-height: 21px;
            text-align: left;
            font-style: normal;
            margin-bottom: 0px;
          }
          .bold {
            font-weight: bold;
            font-size: 15px;
            color: #000000;
            line-height: 21px;
          }
          .divide {
            width: 1px;
            height: 11px;
            background: #cccfd7;
            margin: 0 12px;
          }
        }
        .editBlock {
          margin-top: 2px;
          background: #f8f8f8;
          border-radius: 8px;
          padding: 16px;
          ::v-deep .el-form-item {
            display: inline-flex;
            flex-direction: column;
            min-width: 251px;
            width: calc(33% - 40px);
            margin-right: 24px;
            margin-bottom: 16px;
            margin-top: 0px;
            &.textAreaFormItem {
              width: 100%;
              margin-bottom: 14px;
              .el-textarea {
                textarea {
                }
              }
            }
            &.wholeLineFormItem {
              width: 100%;
              margin-bottom: 0px;
              .el-form-item__content {
                display: flex;
                justify-content: space-between;
                .submitButtons {
                  width: 100%;
                  display: flex;
                  justify-content: flex-end;
                  margin-top: 11px;
                  .el-button {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100px;
                    height: 30px;
                    background: #ffffff;
                    border-radius: 4px;
                    border: 1px solid #cdcdcd;
                    font-family: PingFang-SC, PingFang-SC;
                    font-weight: bold;
                    font-size: 14px;
                    text-align: left;
                    font-style: normal;
                    padding: 0;
                    &.el-button--primary {
                      width: 100px;
                      height: 30px;
                      background: #4880ff;
                      border-radius: 4px;
                    }
                  }
                }
                &::before {
                  display: none;
                }
                &::after {
                  display: none;
                }
              }
            }
            .el-form-item__label {
              height: 22px;
              font-family: PingFangSC, PingFang SC;
              font-weight: 400;
              font-size: 14px;
              color: #666660;
              line-height: 20px;
              text-align: left;
              font-style: normal;
            }
          }
          .submitButtons {
            display: flex;
            justify-content: flex-end;
            .el-button {
              display: flex;
              justify-content: center;
              align-items: center;
              width: 100px;
              height: 30px;
              background: #ffffff;
              border-radius: 4px;
              border: 1px solid #cdcdcd;
              font-family: PingFang-SC, PingFang-SC;
              font-weight: bold;
              font-size: 14px;
              text-align: left;
              font-style: normal;
              padding: 0;
              &.el-button--primary {
                width: 100px;
                height: 30px;
                background: #4880ff;
                border-radius: 4px;
              }
            }
          }
        }
      }
    }
  }
  // ::v-deep .el-date-editor .el-range-input {
  //   background-color: #ffffff;
  // }
  ::v-deep .el-textarea {
    margin-top: 4px;
  }
  ::v-deep .el-select {
    .el-input__inner {
      width: 250px;
    }
  }
}
::v-deep .el-textarea .el-input__count {
  background-color: transparent;
  bottom: -33px;
}
::v-deep .el-textarea .el-input__count {
  background-color: transparent;
}
</style>